# %% md
# 学习seaborn

import matplotlib.pyplot as plt
# %%
import numpy as np
import pandas as pd
import seaborn as sns

sns.set()

# %%
data = pd.DataFrame(np.zeros([2, 3]), columns=list('abc'))

# %%
rng = np.random.RandomState(42)
x = 10 * rng.rand(50)
y = 2 * x - 1 + rng.randn(50)
plt.scatter(x, y)

# %%
from sklearn.linear_model import LinearRegression

model = LinearRegression(fit_intercept=True)

# %%
X = x[:, np.newaxis]

# %%
model.fit(X, y)

# %% md
# model.coef_
# Out[3]: array([1.9776566])
# model.intercept_
# Out[4]: -0.9033107255311164


# %%
xfit = np.linspace(-1, 11)
Xfit = xfit[:, np.newaxis]
yfit = model.predict(Xfit)

plt.scatter(x, y)
plt.plot(xfit, yfit)

plt.show()
